#include "config.h"

namespace sleek
{
    namespace core
    {
        namespace device
        {
            Config::Config()
            {
                fullscreen = false;
                screen_bits = 32;
                screen.width = 800;
                screen.height = 600;
            }
            Config::~Config()
            {
            }
            void Config::read(os::stringc file)
            {
                FILE *in = fopen(file.c_str(),"r");
                if(!in){ printf("Can't read file \"%s\"\n", file.c_str()); return; }
                fscanf(in,"Fullescreen = %ld\n"
                                  "ScreenSize = %u, %u\n"
                                  "ScreenBits = %d\n", &fullscreen, &screen.width, &screen.height, &screen_bits);
                fclose(in);
                printf("Read config: \"%s\"\n", file.c_str());
            }
            void Config::write(os::stringc file)
            {
                FILE *out = fopen(file.c_str(),"wb+");
                if(!out){ printf("Can't read file \"%s\"\n", file.c_str()); return; }
                fprintf(out,"Fullescreen = %ld\n"
                                     "ScreenSize = %u, %u\n"
                                     "ScreenBits = %d\n", fullscreen, screen.width, screen.height, screen_bits);
                fclose(out);
                printf("Write config: \"%s\"\n", file.c_str());
            }
        }
    }
}
